package rexsee.natives;

import rexsee.core.browser.Browser;
import android.view.GestureDetector.OnDoubleTapListener;
import android.view.GestureDetector.OnGestureListener;
import android.view.MotionEvent;

public class ViewGestureListener
		implements
		OnDoubleTapListener,
		OnGestureListener {

	private final Browser mBrowser;
	private final String mId;

	public ViewGestureListener(Browser browser, String id) {
		mBrowser = browser;
		mId = id;
	}

	@Override
	public boolean onDoubleTap(MotionEvent e) {
		mBrowser.eventList.run(RexseeJavaView.EVENT_ONJAVAVIEWDOUBLECLICK, new String[]{mId, String.valueOf(e.getX()), String.valueOf(e.getY())});
		return false;
	}
	@Override
	public boolean onDoubleTapEvent(MotionEvent e) {
		return false;
	}
	@Override
	public boolean onSingleTapConfirmed(MotionEvent e) {
		mBrowser.eventList.run(RexseeJavaView.EVENT_ONJAVAVIEWCLICK, new String[]{mId, String.valueOf(e.getX()), String.valueOf(e.getY())});
		return false;
	}
	@Override
	public boolean onDown(MotionEvent e) {
		return false;
	}
	@Override
	public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
		mBrowser.eventList.run(RexseeJavaView.EVENT_ONJAVAVIEWFLING, new String[]{mId, String.valueOf(e1.getX()), String.valueOf(e1.getY()), String.valueOf(e2.getX()), String.valueOf(e2.getY())});
		return false;
	}
	@Override
	public void onLongPress(MotionEvent e) {
		mBrowser.eventList.run(RexseeJavaView.EVENT_ONJAVAVIEWLONGPRESS, new String[]{mId, String.valueOf(e.getX()), String.valueOf(e.getY())});
	}
	@Override
	public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
		mBrowser.eventList.run(RexseeJavaView.EVENT_ONJAVAVIEWTOUCHSCROLL, new String[]{mId, String.valueOf(e1.getX()), String.valueOf(e1.getY()), String.valueOf(e2.getX()), String.valueOf(e2.getY())});
		return false;
	}
	@Override
	public void onShowPress(MotionEvent e) {
	}
	@Override
	public boolean onSingleTapUp(MotionEvent e) {
		return false;
	}
}
